/**
   *服务后台控制线程
 */    
void *backCtrl(void *arg)
{   
     
    char d[20]="";
    char s[20];
    char commandpath[100];
    strcpy(commandpath,path);
    strcat(commandpath,"command/command");
    FILE *command; 
    printf(commandpath);
    while( IsDestroy==0){
              sleep(5);
            strcpy(s,d);
        
       //***********读取控制命令*******/
    	if((command=fopen(commandpath,"r"))==NULL){
         	 printf("{'msg':'system error'}");
             return;
    	}
    	if(!feof(command)){//命令不为空读取命令
 
    		fscanf(command,"%s",d);
    		fclose(command);       
            if(strcmp(s,d)==0)//命令没变
            continue;        	
      	}
   	 else{
         fclose(command);//命令为空继续等待命令
            continue;
      	}

    if(strcmp(d,"stop")==0){//soj stop
            if( IsStart==0){
              printf("{'msg':'severce has already stopped'}");
               continue;
                }
              IsStart=0;
           printf("{'msg':'sverce stop'}");
      	}
       else if(strcmp(d,"start")==0){//soj start
                  if( IsStart==1){
              	 printf("{'msg':'severce has already started'}");
                       continue;
                	}
                  IsStart=1;
          printf("{'msg':'severce start'}");
      	 } 
         else if(strcmp(d,"destroy")==0){//soj destroy                
                  printf("{'msg':'severce destroy'");      
                  IsStart=0;
                  IsDestroy=1;//程序终止                                                    
                  return;//线程终止
           }
         else
                printf("{'msg':'服务没有此命令'}");
       
    }
  
   
  
}